package com.xgst.land.activity.check

import android.graphics.Color
import android.text.TextUtils
import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xgst.land.R
import com.xgst.land.bean.IceboxItemListBean

class ItemAdapter(checkId:Int):BaseQuickAdapter<IceboxItemListBean, BaseViewHolder>(R.layout.item_list_layout) {
    private var checkId = checkId
    override fun convert(holder: BaseViewHolder, item: IceboxItemListBean) {
        val line = holder.getView<View>(R.id.line)
        if (getItemPosition(item) == 0) {
            line.visibility = View.GONE
        } else {
            line.visibility = View.VISIBLE
        }
        holder.setText(R.id.tvName, item.name)
        if (TextUtils.isEmpty(item.disable)) {
            holder.setTextColor(R.id.tvName, Color.BLACK)
        } else {
            holder.setTextColor(R.id.tvName, context.getColor(R.color.colorTextGray))
        }

        if(checkId == item.id){
            holder.setBackgroundColor(R.id.tvName,context.getColor(R.color.blue))
        }else{
            holder.setBackgroundColor(R.id.tvName,context.getColor(R.color.white))
        }
    }
}